package cn.hdc.os.biz.impl;

import cn.hdc.os.biz.EmployeeBiz;
import cn.hdc.os.dao.EmployeeDao;
import cn.hdc.os.entity.Employee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("employeeBiz")
//员工业务层，调用持久层
public class EmployeeImpl implements EmployeeBiz {
    @Autowired
    @Qualifier("employeeDao")
    private EmployeeDao employeeDao;

    //增加一个用户，初始化密码为000000，这里演示只是为了凸显业务层的作用
    @Override
    public void add(Employee employee) {
        employee.setPassword("000000");
        employeeDao.insert(employee);
    }

    //编辑用户
    @Override
    public void edit(Employee employee) {
        employeeDao.update(employee);
    }

    //删除用户
    @Override
    public void remove(String sn) {
        employeeDao.delete(sn);
    }

    //根据sn查找用户
    @Override
    public Employee get(String sn) {
        return employeeDao.select(sn);
    }

    //查找所有用户
    @Override
    public List<Employee> getAll() {
        return employeeDao.selectAll();
    }
}
